@import './global.css';
@import './base.css';

#app {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  font-weight: normal;
  /* 确保应用占满整个视口 */
  overflow: hidden;
}

a,
.green {
  text-decoration: none;
  color: hsla(160, 100%, 37%, 1);
  transition: 0.4s;
  padding: 3px;
}

@media (hover: hover) {
  a:hover {
    background-color: hsla(160, 100%, 37%, 0.2);
  }
}

/* 移除导致页面居中的媒体查询 */
/* @media (min-width: 1024px) {
  body {
    display: flex;
    place-items: center;
  }

  #app {
    display: block;
    padding: 0 2rem;
    padding-bottom: 2rem;
  }
} */

/* 确保页面占满整个视口 */
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

html {
  height: 100%;
  overflow: hidden;
}

/* Dify智能体样式 - 默认只显示小图标 */
#dify-chatbot-bubble-button {
  background-color: #1C64F2 !important;
  z-index: 9999 !important;
  /* 调整位置，避免与页面内容重叠 */
  bottom: 2rem !important;
  right: 2rem !important;
  /* 确保小图标始终可见 */
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#dify-chatbot-bubble-window {
  width: 18rem !important;
  height: 28rem !important;
  z-index: 9998 !important;
  /* 调整位置，避免与页面内容重叠 */
  bottom: 5rem !important;
  right: 2rem !important;
  /* 确保在小屏幕上也能正常显示 */
  max-width: calc(100vw - 4rem) !important;
  max-height: calc(100vh - 8rem) !important;
  /* 默认隐藏聊天窗口，只显示小图标 */
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: all 0.3s ease !important;
  /* 确保聊天窗口不会影响主页面布局 */
  position: fixed !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border-radius: 8px !important;
  /* 确保聊天窗口不会影响页面滚动 */
  overflow: hidden !important;
  /* 确保关闭按钮有足够空间 */
  padding-top: 10px !important;
}

/* 当聊天窗口打开时的样式 */
#dify-chatbot-bubble-window[style*="display: block"],
#dify-chatbot-bubble-window[style*="display:block"],
#dify-chatbot-bubble-window.show {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* 关闭按钮样式 */
.dify-close-btn {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  width: 28px !important;
  height: 28px !important;
  background: #ff4757 !important;
  color: white !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-size: 20px !important;
  font-weight: bold !important;
  z-index: 10000 !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  border: 2px solid white !important;
  outline: none !important;
  user-select: none !important;
  line-height: 1 !important;
  text-align: center !important;
}

.dify-close-btn:hover {
  background: #ff3742 !important;
  transform: scale(1.1) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.dify-close-btn:active {
  transform: scale(0.95) !important;
  background: #ff2e3a !important;
}

.dify-close-btn:focus {
  outline: 2px solid #ff6b7a !important;
  outline-offset: 2px !important;
}

/* 确保关闭按钮在聊天窗口打开时始终可见 */
#dify-chatbot-bubble-window:not([style*="display: none"]) .dify-close-btn,
#dify-chatbot-bubble-window:not([style*="display:none"]) .dify-close-btn,
#dify-chatbot-bubble-window.show .dify-close-btn {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* 确保Dify智能体在其他元素之上 */
#dify-chatbot-bubble-button,
#dify-chatbot-bubble-window {
  position: fixed !important;
}

/* 确保主页面布局不受Dify智能体影响 */
body {
  /* 确保页面滚动正常 */
  overflow-x: hidden !important;
}

#app {
  /* 确保应用容器不受影响 */
  position: relative !important;
  z-index: 1 !important;
}

/* 响应式设计 - 小屏幕适配 */
@media (max-width: 768px) {
  #dify-chatbot-bubble-window {
    width: calc(100vw - 2rem) !important;
    height: calc(100vh - 8rem) !important;
    bottom: 5rem !important;
    right: 1rem !important;
    left: 1rem !important;
  }
  
  #dify-chatbot-bubble-button {
    bottom: 1rem !important;
    right: 1rem !important;
  }
  
  #app {
    padding-bottom: 2rem;
  }
}

/* 确保页面内容不被Dify智能体遮挡 */
.realtime-dashboard,
.dashboard-content {
  /* 移除底部边距，因为现在只有小图标 */
  margin-bottom: 2rem;
}

/* 在小屏幕上进一步调整 */
@media (max-width: 480px) {
  #dify-chatbot-bubble-window {
    width: calc(100vw - 1rem) !important;
    height: calc(100vh - 6rem) !important;
    bottom: 4rem !important;
    right: 0.5rem !important;
    left: 0.5rem !important;
  }
  
  #dify-chatbot-bubble-button {
    bottom: 0.5rem !important;
    right: 0.5rem !important;
  }
}
